home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / Xm / XmeResolvePartOffsets.z / XmeResolvePartOffsets
Encoding:
Text File  |  2002-10-03  |  11.4 KB  |  199 lines

  1.  
  2.  
  3.  
  4.      XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX)))) UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss - Allows writing of upward-compatible
  10.           applications and widgets
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           #include <Xm/XmP.h>
  14.           vvvvooooiiiidddd XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss(
  15.           WWWWiiiiddddggggeeeettttCCCCllllaaaassssssss wwwwiiiiddddggggeeeetttt____ccccllllaaaassssssss,
  16.           XXXXmmmmOOOOffffffffsssseeeettttPPPPttttrrrr ****ooooffffffffsssseeeetttt,
  17.           XXXXmmmmOOOOffffffffsssseeeettttPPPPttttrrrr ****ccccoooonnnnssssttttrrrraaaaiiiinnnntttt____ooooffffffffsssseeeetttt);
  18.  
  19.      VVVVEEEERRRRSSSSIIIIOOOONNNN
  20.           This page documents Motif 2.1.
  21.  
  22.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  23.           The use of offset records requires two extra global
  24.           variables per widget class.  The variables consist of
  25.           pointers to arrays of offsets into the widget record and
  26.           constraint record for each part of the widget structure.
  27.           The XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss function allocates the offset
  28.           records needed by an application to guarantee upward-
  29.           compatible access to widget instance and constraint records
  30.           by applications and widgets.  These offset records are used
  31.           by the widget to access all of the widget's variables.  A
  32.           widget needs to take the steps described in the following
  33.           paragraphs.
  34.  
  35.           Instead of creating a resource list, the widget creates an
  36.           offset resource list.  To accomplish this, use the
  37.           XXXXmmmmPPPPaaaarrrrttttRRRReeeessssoooouuuurrrrcccceeeestructure and the XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt macro.  The
  38.           XXXXmmmmPPPPaaaarrrrttttRRRReeeessssoooouuuurrrrcccceeee data structure looks just like a resource
  39.           list, but, instead of having one integer for its offset, it
  40.           has two shorts.  This structure is put into the class record
  41.           as if it were a normal resource list. Instead of using
  42.           XXXXttttOOOOffffffffsssseeeetttt for the offset, the widget uses XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt.
  43.  
  44.           If the widget is a subclass of the CCCCoooonnnnssssttttrrrraaaaiiiinnnntttt class and it
  45.           defines additional constraint resources, create an offset
  46.           resource list for the constraint part as well.  Instead of
  47.           using XXXXttttOOOOffffffffsssseeeetttt for the offset, the widget uses
  48.           XXXXmmmmCCCCoooonnnnssssttttrrrraaaaiiiinnnnttttPPPPaaaarrrrttttOOOOffffffffsssseeeettttin the constraint resource list.
  49.  
  50.           Do not create parts that do not preserve alignment (for
  51.           example, a widget part containing a single Boolean).
  52.  
  53.           XmPartResource resources[] = {
  54.                   {       BarNxyz, BarCXyz, XmRBoolean, sizeof(Boolean),
  55.                           XmPartOffset(Bar,xyz), XmRImmediate, (XtPointer)False } };
  56.           XmPartResource constraints[] = {
  57.                   {       BarNmaxWidth, BarNMaxWidth,
  58.                           XmRDimension, sizeof(Dimension),
  59.                           XmConstraintPartOffset(Bar,max_width),
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 10/3/02)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX)))) UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  71.  
  72.  
  73.  
  74.                           XmRImmediate, (XtPointer)100 } };
  75.  
  76.           Instead of putting the widget size in the class record, the
  77.           widget puts the widget part size in the same field.  If the
  78.           widget is a subclass of the CCCCoooonnnnssssttttrrrraaaaiiiinnnntttt class, instead of
  79.           putting the widget constraint record size in the class
  80.           record, the widget puts the widget constraint part size in
  81.           the same field.
  82.  
  83.           Instead of putting XXXXttttVVVVeeeerrrrssssiiiioooonnnn in the class record, the widget
  84.           puts XXXXttttVVVVeeeerrrrssssiiiioooonnnnDDDDoooonnnnttttCCCChhhheeeecccckkkk in the class record.
  85.  
  86.           Define a variable of type XXXXmmmmOOOOffffffffsssseeeettttPPPPttttrrrr to point to the offset
  87.           record.  If the widget is a subclass of the CCCCoooonnnnssssttttrrrraaaaiiiinnnntttt
  88.           class, define a variable of type XXXXmmmmOOOOffffffffsssseeeettttPPPPttttrrrr to point to the
  89.           constraint offset record.  These can be part of the widget's
  90.           class record or separate global variables.
  91.  
  92.           In class initialization, the widget calls
  93.           XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss, passing it pointers to the class
  94.           record, the address of the offset record, and the address of
  95.           the constraint offset record.  If the widget is not a
  96.           subclass of the CCCCoooonnnnssssttttrrrraaaaiiiinnnntttt class, it should pass _N_U_L_L as the
  97.           address of the CCCCoooonnnnssssttttrrrraaaaiiiinnnntttt offset record.  This does several
  98.           things:
  99.  
  100.              +o  Adds the superclass (which, by definition, has already
  101.                 been initialized) size field to the part size field
  102.  
  103.              +o  If the widget is a subclass of the CCCCoooonnnnssssttttrrrraaaaiiiinnnntttt class,
  104.                 adds the superclass constraint size field to the
  105.                 constraint size field
  106.  
  107.              +o  Allocates an array based upon the number of
  108.                 superclasses
  109.  
  110.              +o  If the widget is a subclass of the CCCCoooonnnnssssttttrrrraaaaiiiinnnntttt class,
  111.                 allocates an array for the constraint offset record
  112.  
  113.              +o  Fills in the offsets of all the widget parts and
  114.                 constraint parts with the appropriate values, which
  115.                 can be determined by examining the size fields of all
  116.                 superclass records
  117.  
  118.              +o  Uses the part offset array to modify the offset
  119.                 entries in the resource list to be real offsets, in
  120.                 place
  121.  
  122.           The widget defines a constant that will be the index to its
  123.           part structure in the offsets array.  The value should be 1
  124.           greater than the index of the widget's superclass.
  125.           Constants defined for all Xm widgets can be found in header
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 10/3/02)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX)))) UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  137.  
  138.  
  139.  
  140.           file XXXXmmmm////XXXXmmmmPPPP....hhhh.
  141.  
  142.           #define BarIndex (XmBulletinBIndex + 1)
  143.  
  144.           Instead of accessing fields directly, the widget must always
  145.           go through the offset table.  The XXXXmmmmFFFFiiiieeeelllldddd and
  146.           XXXXmmmmCCCCoooonnnnssssttttrrrraaaaiiiinnnnttttFFFFiiiieeeelllldddd macros help you access these fields.
  147.           Because the XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt, XXXXmmmmCCCCoooonnnnssssttttrrrraaaaiiiinnnnttttPPPPaaaarrrrttttOOOOffffffffsssseeeetttt, XXXXmmmmFFFFiiiieeeelllldddd,
  148.           and XXXXmmmmCCCCoooonnnnssssttttrrrraaaaiiiinnnnttttFFFFiiiieeeellllddddmacros concatenate things, you must
  149.           ensure that there is no space after the part argument.  For
  150.           example, the following macros do not work because of the
  151.           space after the part (Label) argument:
  152.  
  153.           XmField(w, offset, Label, text, char *)
  154.           XmPartOffset(Label, text).
  155.  
  156.           You must not have any spaces after the part (Label)
  157.           argument, illustrated as follows:
  158.  
  159.           XmField(w, offset, Label, text, char *)
  160.           XmPartOffset(Label, text).
  161.  
  162.           You can define macros for each field to make this easier.
  163.           For example, the following shows how to define a macro for
  164.           an enumerated field _x_y_z in widget BBBBaaaarrrr:
  165.  
  166.           #define BarXyz(w) \
  167.                   XmField(w,offsets,Bar,xyz,XtEnum)
  168.  
  169.           Define a macro for constraint field _m_a_x__w_i_d_t_h as follows:
  170.  
  171.           #define BarMaxWidth(w) \
  172.                   XmConstraintField(w,constraint_offsets,Bar,max_width,Dimension)
  173.  
  174.           The arguments for XXXXmmmmeeeeRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss are as follows:
  175.  
  176.           _w_i_d_g_e_t__c_l_a_s_s
  177.                     Specifies the widget class pointer for the created
  178.                     widget.
  179.  
  180.           _o_f_f_s_e_t    Returns the offset record.
  181.  
  182.           _c_o_n_s_t_r_a_i_n_t__o_f_f_s_e_t
  183.                     Returns the constraint offset record.
  184.  
  185.      RRRREEEELLLLAAAATTTTEEEEDDDD IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  186.           XXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss(3).
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 10/3/02)
  196.  
  197.  
  198.  
  199.